/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.swt.mto.thithu.model;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.model.BaseModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.util.PortalUtil;

import com.swt.mto.thithu.service.QuizCategoryLocalServiceUtil;

import java.io.Serializable;

import java.lang.reflect.Proxy;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * @author tuan.nguyen
 */
public class QuizCategoryClp extends BaseModelImpl<QuizCategory>
	implements QuizCategory {
	public QuizCategoryClp() {
	}

	public Class<?> getModelClass() {
		return QuizCategory.class;
	}

	public String getModelClassName() {
		return QuizCategory.class.getName();
	}

	public long getPrimaryKey() {
		return _quizCategoryId;
	}

	public void setPrimaryKey(long primaryKey) {
		setQuizCategoryId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_quizCategoryId);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	@Override
	public Map<String, Object> getModelAttributes() {
		Map<String, Object> attributes = new HashMap<String, Object>();

		attributes.put("quizCategoryId", getQuizCategoryId());
		attributes.put("parentId", getParentId());
		attributes.put("createUserId", getCreateUserId());
		attributes.put("modifyUserId", getModifyUserId());
		attributes.put("title", getTitle());
		attributes.put("description", getDescription());
		attributes.put("createDate", getCreateDate());
		attributes.put("modifydate", getModifydate());

		return attributes;
	}

	@Override
	public void setModelAttributes(Map<String, Object> attributes) {
		Long quizCategoryId = (Long)attributes.get("quizCategoryId");

		if (quizCategoryId != null) {
			setQuizCategoryId(quizCategoryId);
		}

		Long parentId = (Long)attributes.get("parentId");

		if (parentId != null) {
			setParentId(parentId);
		}

		Long createUserId = (Long)attributes.get("createUserId");

		if (createUserId != null) {
			setCreateUserId(createUserId);
		}

		Long modifyUserId = (Long)attributes.get("modifyUserId");

		if (modifyUserId != null) {
			setModifyUserId(modifyUserId);
		}

		String title = (String)attributes.get("title");

		if (title != null) {
			setTitle(title);
		}

		String description = (String)attributes.get("description");

		if (description != null) {
			setDescription(description);
		}

		Date createDate = (Date)attributes.get("createDate");

		if (createDate != null) {
			setCreateDate(createDate);
		}

		Date modifydate = (Date)attributes.get("modifydate");

		if (modifydate != null) {
			setModifydate(modifydate);
		}
	}

	public long getQuizCategoryId() {
		return _quizCategoryId;
	}

	public void setQuizCategoryId(long quizCategoryId) {
		_quizCategoryId = quizCategoryId;
	}

	public long getParentId() {
		return _parentId;
	}

	public void setParentId(long parentId) {
		_parentId = parentId;
	}

	public long getCreateUserId() {
		return _createUserId;
	}

	public void setCreateUserId(long createUserId) {
		_createUserId = createUserId;
	}

	public String getCreateUserUuid() throws SystemException {
		return PortalUtil.getUserValue(getCreateUserId(), "uuid",
			_createUserUuid);
	}

	public void setCreateUserUuid(String createUserUuid) {
		_createUserUuid = createUserUuid;
	}

	public long getModifyUserId() {
		return _modifyUserId;
	}

	public void setModifyUserId(long modifyUserId) {
		_modifyUserId = modifyUserId;
	}

	public String getModifyUserUuid() throws SystemException {
		return PortalUtil.getUserValue(getModifyUserId(), "uuid",
			_modifyUserUuid);
	}

	public void setModifyUserUuid(String modifyUserUuid) {
		_modifyUserUuid = modifyUserUuid;
	}

	public String getTitle() {
		return _title;
	}

	public void setTitle(String title) {
		_title = title;
	}

	public String getDescription() {
		return _description;
	}

	public void setDescription(String description) {
		_description = description;
	}

	public Date getCreateDate() {
		return _createDate;
	}

	public void setCreateDate(Date createDate) {
		_createDate = createDate;
	}

	public Date getModifydate() {
		return _modifydate;
	}

	public void setModifydate(Date modifydate) {
		_modifydate = modifydate;
	}

	public BaseModel<?> getQuizCategoryRemoteModel() {
		return _quizCategoryRemoteModel;
	}

	public void setQuizCategoryRemoteModel(BaseModel<?> quizCategoryRemoteModel) {
		_quizCategoryRemoteModel = quizCategoryRemoteModel;
	}

	public void persist() throws SystemException {
		if (this.isNew()) {
			QuizCategoryLocalServiceUtil.addQuizCategory(this);
		}
		else {
			QuizCategoryLocalServiceUtil.updateQuizCategory(this);
		}
	}

	@Override
	public QuizCategory toEscapedModel() {
		return (QuizCategory)Proxy.newProxyInstance(QuizCategory.class.getClassLoader(),
			new Class[] { QuizCategory.class }, new AutoEscapeBeanHandler(this));
	}

	@Override
	public Object clone() {
		QuizCategoryClp clone = new QuizCategoryClp();

		clone.setQuizCategoryId(getQuizCategoryId());
		clone.setParentId(getParentId());
		clone.setCreateUserId(getCreateUserId());
		clone.setModifyUserId(getModifyUserId());
		clone.setTitle(getTitle());
		clone.setDescription(getDescription());
		clone.setCreateDate(getCreateDate());
		clone.setModifydate(getModifydate());

		return clone;
	}

	public int compareTo(QuizCategory quizCategory) {
		long primaryKey = quizCategory.getPrimaryKey();

		if (getPrimaryKey() < primaryKey) {
			return -1;
		}
		else if (getPrimaryKey() > primaryKey) {
			return 1;
		}
		else {
			return 0;
		}
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		QuizCategoryClp quizCategory = null;

		try {
			quizCategory = (QuizCategoryClp)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long primaryKey = quizCategory.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(17);

		sb.append("{quizCategoryId=");
		sb.append(getQuizCategoryId());
		sb.append(", parentId=");
		sb.append(getParentId());
		sb.append(", createUserId=");
		sb.append(getCreateUserId());
		sb.append(", modifyUserId=");
		sb.append(getModifyUserId());
		sb.append(", title=");
		sb.append(getTitle());
		sb.append(", description=");
		sb.append(getDescription());
		sb.append(", createDate=");
		sb.append(getCreateDate());
		sb.append(", modifydate=");
		sb.append(getModifydate());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(28);

		sb.append("<model><model-name>");
		sb.append("com.swt.mto.thithu.model.QuizCategory");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>quizCategoryId</column-name><column-value><![CDATA[");
		sb.append(getQuizCategoryId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>parentId</column-name><column-value><![CDATA[");
		sb.append(getParentId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>createUserId</column-name><column-value><![CDATA[");
		sb.append(getCreateUserId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>modifyUserId</column-name><column-value><![CDATA[");
		sb.append(getModifyUserId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>title</column-name><column-value><![CDATA[");
		sb.append(getTitle());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>description</column-name><column-value><![CDATA[");
		sb.append(getDescription());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>createDate</column-name><column-value><![CDATA[");
		sb.append(getCreateDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>modifydate</column-name><column-value><![CDATA[");
		sb.append(getModifydate());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private long _quizCategoryId;
	private long _parentId;
	private long _createUserId;
	private String _createUserUuid;
	private long _modifyUserId;
	private String _modifyUserUuid;
	private String _title;
	private String _description;
	private Date _createDate;
	private Date _modifydate;
	private BaseModel<?> _quizCategoryRemoteModel;
}